package eu.jpereira.trainings.designpatterns.structural.facade;

import static org.mockito.Mockito.*;
import eu.jpereira.trainings.designpatterns.structural.facade.model.Book;
import eu.jpereira.trainings.designpatterns.structural.facade.model.Customer;
import eu.jpereira.trainings.designpatterns.structural.facade.model.DispatchReceipt;
import eu.jpereira.trainings.designpatterns.structural.facade.model.Order;
import eu.jpereira.trainings.designpatterns.structural.facade.service.BookDBService;
import eu.jpereira.trainings.designpatterns.structural.facade.service.CustomerDBService;
import eu.jpereira.trainings.designpatterns.structural.facade.service.CustomerNotificationService;
import eu.jpereira.trainings.designpatterns.structural.facade.service.OrderingService;
import eu.jpereira.trainings.designpatterns.structural.facade.service.WharehouseService;

public class DefaultBooktoreFacade implements BookstoreFacade{

	public BookDBService bookDB;
	public CustomerDBService customerDB;
	public CustomerNotificationService customerNotification;
	public OrderingService order;
	public WharehouseService wharehouse;
	
	@Override
	public void placeOrder(String customerId, String isbn) {

		Customer customer =  this.customerDB.findCustomerById(customerId);
		Book book = this.bookDB.findBookByISBN(isbn);
		Order order = this.order.createOrder(customer, book);
		DispatchReceipt dispatchReceipt = this.wharehouse.dispatch(order);
		this.customerNotification.notifyClient(dispatchReceipt);
	}

}
